home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Dema / betonsoldier_spdemo.exe / {app} / Shaders / mesh_LightGlow.fx < prev    next >
Encoding:
Text File  |  2005-07-21  |  9.8 KB  |  323 lines

  1. //------------------------------------------------------------------------------------------------------
  2. //------------------------------------------------------------------------------------------------------
  3. //------------------------------------------------------------------------------------------------------
  4.  
  5. #include "shared.fx"
  6. #include "lighting.fx"
  7. #define FOG_DISABLE
  8. #include "fog.fx"
  9.  
  10. //------------------------------------------------------------------------------------------------------
  11. //- Static parameters
  12. //------------------------------------------------------------------------------------------------------
  13.  
  14. texture            DiffuseMap;
  15. float4            Color; //shared between all occurences of this shader.
  16.  
  17. //------------------------------------------------------------------------------------------------------
  18. //------------------------------------------------------------------------------------------------------
  19. //------------------------------------------------------------------------------------------------------
  20.  
  21. struct    GlowVertexShaderInput
  22. {
  23.     float4    Position    :    POSITION;
  24.     float2    DiffuseUv    :    TEXCOORD0;    
  25. };
  26.  
  27. //------------------------------------------------------------------------------------------------------
  28.  
  29. struct    GlowVertexShaderOutput
  30. {
  31.     float4    Position    :    POSITION;
  32.     float4    Color        :    COLOR0;
  33.     float2    DiffuseUv    :    TEXCOORD0;
  34.     FOG_OPTION_VERTEX_FIELD
  35. };
  36.  
  37. //------------------------------------------------------------------------------------------------------
  38. //------------------------------------------------------------------------------------------------------
  39. //------------------------------------------------------------------------------------------------------
  40.  
  41. GlowVertexShaderOutput    GlowVertexShaderTech1Pass1(const GlowVertexShaderInput input);
  42.  
  43. //------------------------------------------------------------------------------------------------------
  44. //------------------------------------------------------------------------------------------------------
  45. //------------------------------------------------------------------------------------------------------
  46.  
  47. GlowVertexShaderOutput    GlowVertexShaderTech1Pass1(const GlowVertexShaderInput input)
  48. {
  49.     GlowVertexShaderOutput output;
  50.     
  51.     // output position into world+view+projection space
  52.     output.Position = mul (input.Position,WorldCameraProjection);
  53.         
  54.     // Diffuse Uv output
  55.     output.DiffuseUv = input.DiffuseUv;
  56.     
  57.     // use color0 to store the fade factor!!
  58.     output.Color = Color;
  59.     
  60.     // fog computation
  61.     FOG_OPTION_COMPUTE(output, output.Position);    
  62.         
  63.     return output;
  64. }
  65.  
  66. //------------------------------------------------------------------------------------------------------
  67. //------------------------------------------------------------------------------------------------------
  68. //------------------------------------------------------------------------------------------------------
  69.  
  70. GlowVertexShaderOutput    GlowVertexShaderTransformedPosition(const GlowVertexShaderInput input)
  71. {
  72.     GlowVertexShaderOutput output;
  73.  
  74.     output.Position        = mul(input.Position, World);
  75.     output.DiffuseUv    = input.DiffuseUv;
  76.     output.Color.rgba    = Color;
  77.     
  78.     return output;
  79. }
  80.  
  81. //------------------------------------------------------------------------------------------------------
  82. //------------------------------------------------------------------------------------------------------
  83. //------------------------------------------------------------------------------------------------------
  84. technique    Glow
  85. <
  86.     int Priority = 0;
  87.     int NeedSorting    = 1;
  88.     int TechniqueIndex = 0;
  89.     int DeviceType = HWSHADER_ONLY;
  90.     int LightingType = INTEGRATED_LIGHTING;
  91.     string RenderingType = "Standard";
  92. >
  93. {
  94.     pass pass1
  95.     {
  96.         Texture[0]            = <DiffuseMap>;
  97.         MinFilter[0]        = LINEAR;
  98.         MagFilter[0]        = LINEAR;
  99.         MipFilter[0]        = LINEAR;
  100.         AddressU[0]            = CLAMP;
  101.         AddressV[0]            = CLAMP;
  102.         CullMode            = CW;
  103.         ZEnable                = false;//true;
  104.         ZFunc                = ALWAYS;
  105.         ZWriteEnable        = true;
  106.         
  107.         AlphaTestEnable        = false;
  108.         AlphaBlendEnable    = true;        //use alpha blend !!! I beg thee.        
  109.         SrcBlend            = ONE;        // additive blend.
  110.         DestBlend            = ONE;        // additive blend.
  111.         FOG_OPTION_PARAMETERS;        
  112.  
  113.         VertexShader = compile vs_1_1 GlowVertexShaderTech1Pass1();
  114.         
  115.         PixelShader = 
  116.         asm
  117.         {
  118.             ps_1_1
  119.                          
  120.             tex        t0    // Diffuse map                                    
  121.             
  122.             mul    r0.rgb,t0,v0 + mul r0.a,v0.a,t0.a
  123.             mul    r0.rgb,r0,r0.a
  124.         };
  125.     }
  126. }
  127.  
  128. //------------------------------------------------------------------------------------------------------
  129. //------------------------------------------------------------------------------------------------------
  130. //------------------------------------------------------------------------------------------------------
  131. technique    GlowAlpha
  132. <
  133.     int Priority = 0;
  134.     int NeedSorting    = 1;
  135.     int TechniqueIndex = 1;
  136.     int DeviceType = HWSHADER_ONLY;
  137.     int LightingType = INTEGRATED_LIGHTING;
  138.     string RenderingType = "Standard";
  139. >
  140. {
  141.     pass pass1
  142.     {
  143.         Texture[0]            = <DiffuseMap>;
  144.         MinFilter[0]        = LINEAR;
  145.         MagFilter[0]        = LINEAR;
  146.         MipFilter[0]        = LINEAR;
  147.         AddressU[0]            = CLAMP;
  148.         AddressV[0]            = CLAMP;
  149.         CullMode            = CW;
  150.         ZEnable                = false;        
  151.         
  152.         AlphaTestEnable        = false;
  153.         AlphaBlendEnable    = true;        //use alpha blend !!! I beg thee.
  154.         SrcBlend            = SRCALPHA;
  155.         DestBlend            = INVSRCALPHA;
  156.         FOG_OPTION_PARAMETERS;
  157.         
  158.         VertexShader = compile vs_1_1 GlowVertexShaderTech1Pass1();
  159.         
  160.         PixelShader = 
  161.         asm
  162.         {
  163.             ps_1_1
  164.                     
  165.             tex        t0    // Diffuse map
  166.                         
  167.             mul r0.rgb, t0, v0 + mul r0.a, t0.a, v0.a            
  168.         };
  169.     }
  170. }
  171.  
  172.  
  173. //------------------------------------------------------------------------------------------------------
  174. //------------------------------------------------------------------------------------------------------
  175. //------------------------------------------------------------------------------------------------------
  176. technique    GlowScreenSpaceAdditive
  177. <
  178.     int Priority = 0;
  179.     int NeedSorting    = 1;
  180.     int TechniqueIndex = 2;
  181.     int DeviceType = HWSHADER_ONLY;
  182.     int LightingType = INTEGRATED_LIGHTING;
  183.     string RenderingType = "Standard";
  184. >
  185. {
  186.     pass pass1
  187.     {
  188.         Texture[0]            = <DiffuseMap>;
  189.         MinFilter[0]        = LINEAR;
  190.         MagFilter[0]        = LINEAR;
  191.         MipFilter[0]        = LINEAR;
  192.         AddressU[0]            = CLAMP;
  193.         AddressV[0]            = CLAMP;
  194.         CullMode            = NONE;
  195.         ZEnable                = false;
  196.         ZFunc                = ALWAYS;
  197.         ZWriteEnable        = false;
  198.         
  199.         AlphaTestEnable        = false;
  200.         AlphaBlendEnable    = true;        //use alpha blend !!! I beg thee.        
  201.         SrcBlend            = ONE;        // additive blend.
  202.         DestBlend            = ONE;        // additive blend.
  203.         FOG_OPTION_PARAMETERS;        
  204.  
  205.         VertexShader = compile vs_1_1 GlowVertexShaderTransformedPosition();
  206.         
  207.         PixelShader = 
  208.         asm
  209.         {
  210.             ps_1_1
  211.                          
  212.             tex        t0    // Diffuse map                                    
  213.                         
  214.             mul    r0.rgb,t0,v0 + mul r0.a,v0.a,t0.a
  215.             mul    r0.rgb,r0,r0.a
  216.         };
  217.     }
  218. }
  219.  
  220.  
  221. //------------------------------------------------------------------------------------------------------
  222. //------------------------------------------------------------------------------------------------------
  223. //------------------------------------------------------------------------------------------------------
  224. technique    GlowScreenSpaceAlpha
  225. <
  226.     int Priority = 0;
  227.     int NeedSorting    = 1;
  228.     int TechniqueIndex = 3;
  229.     int DeviceType = HWSHADER_ONLY;
  230.     int LightingType = INTEGRATED_LIGHTING;
  231.     string RenderingType = "Standard";
  232. >
  233. {
  234.     pass pass1
  235.     {
  236.         Texture[0]            = <DiffuseMap>;
  237.         MinFilter[0]        = LINEAR;
  238.         MagFilter[0]        = LINEAR;
  239.         MipFilter[0]        = LINEAR;
  240.         AddressU[0]            = CLAMP;
  241.         AddressV[0]            = CLAMP;
  242.         CullMode            = CW;
  243.         ZEnable                = false;        
  244.         
  245.         AlphaTestEnable        = false;
  246.         AlphaBlendEnable    = true;        //use alpha blend !!! I beg thee.
  247.         SrcBlend            = SRCALPHA;
  248.         DestBlend            = INVSRCALPHA;
  249.         FOG_OPTION_PARAMETERS;
  250.         
  251.         VertexShader = compile vs_1_1 GlowVertexShaderTransformedPosition();
  252.         
  253.         PixelShader = 
  254.         asm
  255.         {
  256.             ps_1_1
  257.                     
  258.             tex        t0    // Diffuse map
  259.                         
  260.             mul r0.rgb, t0, v0 + mul r0.a, t0.a, v0.a            
  261.         };
  262.     }
  263. }
  264.  
  265.  
  266. //------------------------------------------------------------------------------------------------------
  267. //------------------------------------------------------------------------------------------------------
  268. //------------------------------------------------------------------------------------------------------
  269. technique    techTnL_0
  270. <
  271.     int Priority = 1;
  272.     int TechniqueIndex = 0;
  273.     int DeviceType = TNL_ONLY;
  274.     int LightingType = INTEGRATED_LIGHTING;
  275.     string RenderingType = "Standard";
  276. >
  277. {
  278.     pass pass1
  279.     {
  280.         WorldTransform[0]    = <WorldCameraProjection>;
  281.         
  282.         Texture[0]            = <DiffuseMap>;
  283.         
  284.         ColorArg1[0]        = TEXTURE;
  285.         ColorOp[0]            = SELECTARG1;
  286.         AlphaArg1[0]        = TEXTURE;
  287.         AlphaOp[0]            = SELECTARG1;
  288.         
  289.         ColorOp[1]            = DISABLE;
  290.         AlphaOp[1]            = DISABLE;
  291.         
  292.         MinFilter[0]        = LINEAR;
  293.         MagFilter[0]        = LINEAR;
  294.         MipFilter[0]        = LINEAR;
  295.         
  296.         AddressU[0]            = WRAP;
  297.         AddressV[0]            = WRAP;
  298.         
  299.         CullMode            = CW;
  300.         ZEnable                = false;
  301.         ZFunc                = ALWAYS;
  302.         ZWriteEnable        = true;
  303.         AlphaBlendEnable    = false;
  304.         AlphaTestEnable        = true;
  305.         AlphaRef            = 192;
  306.         AlphaFunc            = GREATEREQUAL;
  307.         
  308.         VertexShader         = NULL;        
  309.         PixelShader         = NULL;
  310.     }
  311. }
  312. //------------------------------------------------------------------------------------------------------
  313. //------------------------------------------------------------------------------------------------------
  314. //------------------------------------------------------------------------------------------------------
  315.  
  316. #include "mesh_shadow.fx"
  317. #include "mesh_shadow_projector.fx"
  318.  
  319. //------------------------------------------------------------------------------------------------------
  320. //------------------------------------------------------------------------------------------------------
  321. //------------------------------------------------------------------------------------------------------
  322.  
  323.